<extend name="Public:base" />
<block name="header_js">
<script type="text/javascript" src="__DATA__/editor/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__DATA__/editor/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
$(function(){
    var ue = UE.getEditor('inputContent',{
        serverUrl :"{:U('Public/editorMethod')}"
    });
})
</script>

<script type="text/javascript" src="__PUBLIC__/js/calendar.config.js"></script>
<script type="text/javascript" src="__DATA__/static/jq_plugins/iColorPicker/iColorPicker.js"></script>

<script type="text/javascript">
$(function () {
	//缩略图上传
	var litpic_tip = $(".litpic_tip");
	var btn = $(".up-picture-btn span");
	$("#fileupload").wrap("<form id='myupload' action='{:U('Public/upload',array('img_flag' => 1))}' method='post' enctype='multipart/form-data'></form>");
    $("#fileupload").change(function(){
    	if($("#fileupload").val() == "") return;
		$("#myupload").ajaxSubmit({
			dataType:  'json',
			beforeSend: function() {
        		$('#litpic_show').empty();
				btn.html("上传中...");
    		},
			success: function(data) {
				if(data.state == 'SUCCESS'){
					var fileSize = parseFloat(data.info[0].size/1024).toFixed(2);
					litpic_tip.html(""+ data.info[0].name +" 上传成功("+ fileSize +"k)");
					var img = data.info[0].url;//原图
					var timg = data.info[0].turl;//缩略图
					$('#litpic_show').html("<img src='"+timg+"' width='120'>");
					$("#litpic").val(timg);
				}else {
					litpic_tip.html(data.state);		
				}			
					btn.html("添加图片");

			},
			error:function(xhr){
				btn.html("上传失败");
				litpic_tip.html(xhr);
			}
		});
	});


	//文件上传
	var file_tip = $(".file_tip");
	var filebtn = $(".up-file-btn span");
	$("#fileuploadF").wrap("<form id='myfileuploadform' action='{:U('Public/upload')}' method='post' enctype='multipart/form-data'></form>");
    $("#fileuploadF").change(function(){
    	if($("#fileuploadF").val() == "") return;
		$("#myfileuploadform").ajaxSubmit({
			dataType:  'json',
			beforeSend: function() {
				filebtn.html("上传中...");
				file_tip.html("上传中...");
    		},
			success: function(data) {
				if(data.state == 'SUCCESS'){	
					var fileSize = parseFloat(data.info[0].size/1024).toFixed(2);				
					file_tip.html(""+ data.info[0].name +" 上传成功("+ fileSize +"k)");					
					$('#inputDownlink').val("本地下载$$$" + data.info[0].url + '\n' + $('#inputDownlink').val());
					$("#inputFilesize").val(fileSize+"KB");
				}else {
					file_tip.html(data.state);		
				}			
					filebtn.html("添加文件");

			},
			error:function(xhr){
				filebtn.html("上传失败");
				file_tip.html(xhr);
			}
		});
	});

	$('#CK_JumpUrl').click(function(){
            if($(this).prop('checked')) {
                $('#JumpUrlDiv').show();

            }else {
                $('#JumpUrlDiv').hide();
            }
            
     });
	
});




$(function () {

	$('#BrowerPicture').click(function(){
		layer.open({
			type: 2,
			title: 'XYHCMS',
			shadeClose: true,
			shade: 0.5,
			area: ['670px', '350px'],
			content: "{:U('Public/browseFile', array('stype' => 'picture'))}"
		});
	});	

	$('#BrowerFile').click(function(){
		layer.open({
			type: 2,
			title: 'XYHCMS',
			shadeClose: true,
			shade: 0.5,
			area: ['670px', '350px'],
			content: "{:U('Public/browseFile')}"
		});
	});

});


function selectFile(sfile) {
	layer.msg('选择文件成功')
	$('#inputDownlink').val("本地下载$$$" + sfile + '\n' + $('#inputDownlink').val());
}

function selectPicture(sfile) {
	layer.msg('选择文件成功')
	$("#litpic").val(sfile);
	$('#litpic_show').html("<img src='"+sfile+"' width='120'>");
}



</script>
	
</block>

<block name="content">
	<div class="row">
		<div class="col-lg-12">
			<h3 class="page-header"><em class="glyphicon glyphicon-cloud-upload"></em> 
			{$type} 
		    </h3>
		</div>
		
	</div>


	<div class="row">
		<div class="col-lg-12">

				<form method='post' class="form-horizontal" id="form_do" name="form_do" action="{:U('edit')}">											

					<div class="form-group">
						<label for="inputTtitle" class="col-sm-2 control-label">名称</label>
						<div class="col-sm-9">
							<input type="text" name="title" id="inputTtitle" value="{$vo.title}" class="form-control" placeholder="名称" required="required" />								
						</div>
					</div>
					<div class="form-group">
						<label for="inputColor" class="col-sm-2 control-label">标题颜色</label>
						<div class="col-sm-5">
							<input type="text" name="color" id="inputColor" value="{$vo.color}" class="form-control  iColorPicker" placeholder="标题颜色" />									
						</div>
					</div>

					<div class="form-group">
						<label for="inputColor" class="col-sm-2 control-label">自定义属性</label>
						<div class="col-sm-9">
							<foreach name='flagtypelist' item='v'>
							<label class="checkbox-inline"><input type='checkbox' name='flags[]' value='{$key}' <if condition="$key eq B_JUMP">id="CK_JumpUrl"</if> <if condition="($vo['flag'] & $key) eq $key">checked="checked"</if> /> {$v}</label>
							</foreach>								
						</div>
					</div>

					<div class="form-group" id="JumpUrlDiv" <if condition="($vo['flag'] & B_JUMP) eq 0">style="display:none;"</if>>
						<label for="inputJumpurl" class="col-sm-2 control-label">跳转网址</label>
						<div class="col-sm-9">
							<input type="text" name="jumpurl" id="inputJumpurl" value="{$vo.jumpurl}" class="form-control" placeholder="跳转网址" />									
						</div>
					</div>

					<div class="form-group">
						<label for="inputVersion" class="col-sm-2 control-label">软件版本</label>
						<div class="col-sm-5">
							<input type="text" name="version" id="inputVersion" value="{$vo.version}" class="form-control" placeholder="软件版本" />									
						</div>
					</div>

					<div class="form-group">
						<label for="inputUpdatetime" class="col-sm-2 control-label">更新时间</label>
						<div class="col-sm-5">
							<input type="text" name="updatetime" id="inputUpdatetime" value="{$vo.updatetime|date='Y-m-d',###}" class="form-control" placeholder="更新时间" />
							<script type="text/javascript">
			                    Calendar.setup({
			                        weekNumbers: true,
			                        inputField : "inputUpdatetime",
			                        trigger    : "inputUpdatetime",
			                        dateFormat: "%Y-%m-%d",
			                        showTime: true,
			                        minuteStep: 1,
			                        onSelect   : function() {this.hide();}
			                    });
			                </script>									
						</div>
					</div>

					<div class="form-group">
						<label for="inputProName" class="col-sm-2 control-label">所属栏目</label>
						<div class="col-sm-9">
							<select name="cid" class="form-control">
								<volist name="cate" id="v">
								<option value="{$v.id}" <if condition="$vo['cid'] eq $v['id']">selected="selected"</if>>{$v.delimiter}{$v.name}</option>
								</volist>
							</select>									
						</div>
					</div>

					<div class="form-group">
						<label for="litpic" class="col-sm-2 control-label">缩略图</label>
						<div class="col-sm-5">
							    <input type="text" class="form-control" name="litpic" id="litpic" value="{$vo.litpic}" placeholder="缩略图地址" />	
						</div>
						<div class="col-sm-5">
							<button class="btn btn-primary" type="button" id="BrowerPicture"><em class="glyphicon glyphicon-plus-sign"></em> 选择站内图片</button>
								<div class="btn btn-success up-picture-btn">
							        <span><em class="glyphicon glyphicon-plus-sign"></em>添加图片</span>										        
							        <input id="fileupload" type="file" name="mypic">
							    </div>							
						</div>
					</div>

					<div class="form-group">
						<label for="" class="col-sm-2 control-label"></label>
						<div class="col-sm-9">
							<div class="litpic_tip"></div>
							<div id="litpic_show">
								<if condition="$vo['litpic']"><img src="{$vo.litpic}" width='120' /></if>
							</div>							
						</div>
					</div>
					<div class="form-group">
						<label for="litpic" class="col-sm-2 control-label">文件上传</label>
						<div class="col-sm-5">
							<button class="btn btn-primary" type="button" id="BrowerFile"><em class="glyphicon glyphicon-plus-sign"></em> 选择站内文件</button>
								<div class="btn btn-success up-file-btn">
							        <span><em class="glyphicon glyphicon-plus-sign"></em>添加文件</span>										        
							        <input id="fileuploadF" type="file" name="myfile">
							    </div>							
						</div>
					</div>
					<div class="form-group">
						<label for="" class="col-sm-2 control-label"></label>
						<div class="col-sm-9">
							<div class="file_tip"></div>						
						</div>
					</div>

					<div class="form-group">
						<label for="inputKeywords" class="col-sm-2 control-label">文件大小</label>
						<div class="col-sm-9">
							<input type="text" name="filesize" id="inputFilesize" value="{$vo.filesize}" class="form-control" placeholder="文件大小" />						
						</div>
					</div>

					<div class="form-group">
						<label for="inputDescription" class="col-sm-2 control-label">下载地址</label>
						<div class="col-sm-9">
							<textarea rows="5" name="downlink" id="inputDownlink" class="form-control">{$vo.downlink}</textarea>	
							<div>一行一个地址,以$$$分割，如<br/>下载地址1$$$http://a.com</div>	
						</div>
					</div>					

					<div class="form-group">
						<label for="inputContent" class="col-sm-2 control-label">内容</label>
						<div class="col-sm-9">
							<textarea name="content" id="inputContent" style="height: 370px;">{$vo.content}</textarea>						
						</div>
					</div>	
					
					<div class="form-group">
						<label for="inputDescription" class="col-sm-2 control-label">更新日志</label>
						<div class="col-sm-9">
							<textarea name="updatelog" id="inputUpdatelog" class="form-control">{$vo.updatelog}</textarea>								
						</div>
					</div>

					<div class="form-group">
						<label for="inputKeywords" class="col-sm-2 control-label">关键词</label>
						<div class="col-sm-9">
							<input type="text" name="keywords" id="inputKeywords" class="form-control" value="{$vo.keywords}" placeholder="多关键词之间用“,”隔开" />						
						</div>
					</div>

					<div class="form-group">
						<label for="inputDescription" class="col-sm-2 control-label">摘要</label>
						<div class="col-sm-9">
							<textarea name="description" id="inputDescription" class="form-control">{$vo.description}</textarea>								
						</div>
					</div>
					<div class="form-group">
						<label for="inputAuthor" class="col-sm-2 control-label">软件分类</label>
						<div class="col-sm-9">
							<select name="softtype" class="form-control">
								<foreach name='softtypelist' item='v'>
								<option value="{$key}" <if condition="$vo['softtype'] eq $key">selected="selected"</if>>{$v}</option>
								</foreach>
							</select>						
						</div>
					</div>
					<div class="form-group">
						<label for="inputCopyfrom" class="col-sm-2 control-label">软件语言</label>
						<div class="col-sm-9">
							<select name="language" class="form-control">
								<foreach name='softlanguage' item='v'>
								<option value="{$key}" <if condition="$vo['language'] eq $key">selected="selected"</if>>{$v}</option>
								</foreach>
							</select>						
						</div>
					</div>	
					<div class="form-group">
						<label for="inputCopyfrom" class="col-sm-2 control-label">运行环境</label>
						<div class="col-sm-9">
							<label class="checkbox-inline"><input type="checkbox" id="EnvWin0" value="WinXP" name="os[]" <if condition="in_array('WinXP',$vo['os'])"> checked="checked"</if>>WinXP</label>
							<label class="checkbox-inline"><input type="checkbox" id="EnvWin1" value="Win7" name="os[]" <if condition="in_array('Win7',$vo['os'])"> checked="checked"</if>>Win7</label>
							<label class="checkbox-inline"><input type="checkbox" id="EnvWin7" value="Win832" name="os[]" <if condition="in_array('Win832',$vo['os'])"> checked="checked"</if>>Win8</label>
							<label class="checkbox-inline"><input type="checkbox" id="EnvWin6" value="Vista64" name="os[]" <if condition="in_array('Vista64',$vo['os'])"> checked="checked"</if>>Vista 64</label>
							<label class="checkbox-inline"><input type="checkbox" id="EnvWin5" value="Win764" name="os[]" <if condition="in_array('Win764',$vo['os'])"> checked="checked"</if>>Win7 64</label>     
							<label class="checkbox-inline"><input type="checkbox" id="EnvWin8" value="Win864" name="os[]" <if condition="in_array('Win864',$vo['os'])"> checked="checked"</if>>Win8 64</label>
							<label class="checkbox-inline"><input type="checkbox" id="EnvWin2" value="Vista" name="os[]" <if condition="in_array('Vista',$vo['os'])"> checked="checked"</if>>Vista</label>
							<label class="checkbox-inline"><input type="checkbox" id="EnvWin3" value="Win2003" name="os[]" <if condition="in_array('Win2003',$vo['os'])"> checked="checked"</if>>Win2003</label>
							<label class="checkbox-inline"><input type="checkbox" id="EnvWin4" value="WinNT" name="os[]" <if condition="in_array('WinNT',$vo['os'])"> checked="checked"</if>>WinNT</label>					
						</div>
					</div>				

					<div class="form-group">
						<label for="inputPublishtime" class="col-sm-2 control-label">发布时间</label>
						<div class="col-sm-4">
							<input type="text" class="form-control" name="publishtime" id="inputPublishtime" value="{$vo.publishtime|date='Y-m-d H:i:s',###}">
			                <script type="text/javascript">
			                    Calendar.setup({
			                        weekNumbers: true,
			                        inputField : "inputPublishtime",
			                        trigger    : "inputPublishtime",
			                        dateFormat: "%Y-%m-%d %H:%M:%S",
			                        showTime: true,
			                        minuteStep: 1,
			                        onSelect   : function() {this.hide();}
			                    });
			                </script>						
						</div>
					</div>


					<div class="form-group">
						<label for="inputName" class="col-sm-2 control-label">评论</label>
						<div class="col-sm-9">
							<label class="radio-inline">
							 	<input type="radio" name="commentflag" value="1" <if condition="$vo['commentflag'] eq 1">checked="checked"</if> />允许				
							 </label>
							<label class="radio-inline">
							 	<input type="radio" name="commentflag" value="0"  <if condition="$vo['commentflag'] eq 0">checked="checked"</if> />禁止		
							 </label>	
						</div>
					</div>		
					
					<div class="row margin-botton-large">
						<div class="col-sm-offset-2 col-sm-9">
							<input type="hidden" name="id" value="{$vo.id}" />
							<input type="hidden" name="pid" value="{$pid}" />
							<div class="btn-group">
								<button type="submit" class="btn btn-primary"> <i class="glyphicon glyphicon-saved"></i>
									保存
								</button>
								<button type="button" onclick="goUrl('{:U('index')}')" class="btn btn-default"> <i class="glyphicon glyphicon-chevron-left"></i>
									返回
								</button>
							</div>
						</div>
					</div>
				</form>
	
		</div>
	</div>

		


</block>